<div th:fragment="navbar" class="navbar navbar-expand-lg navbar-dark bg-primary">
    <div class="container">
        <a class="navbar-brand" th:href="@{/index}">景点投票系统</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav me-auto">
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/index}" th:classappend="${#httpServletRequest.requestURI == '/index'} ? 'active'">首页</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" th:href="@{/result}" th:classappend="${#httpServletRequest.requestURI == '/result'} ? 'active'">投票结果</a>
                </li>
                <li class="nav-item" th:if="${session.user != null}">
                    <a class="nav-link" th:href="@{/spot/list}" th:classappend="${#httpServletRequest.requestURI.startsWith('/spot')} ? 'active'">景点管理</a>
                </li>
            </ul>
            <ul class="navbar-nav">
                <li class="nav-item" th:if="${session.user == null}">
                    <a class="nav-link" th:href="@{/login}">登录</a>
                </li>
                <li class="nav-item" th:if="${session.user == null}">
                    <a class="nav-link" th:href="@{/register}">注册</a>
                </li>
                <li class="nav-item dropdown" th:if="${session.user != null}">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown">
                        <span th:text="${session.user.realName}"></span>
                    </a>
                    <ul class="dropdown-menu dropdown-menu-end">
                        <li><a class="dropdown-item" href="#">个人中心</a></li>
                        <li><hr class="dropdown-divider"></li>
                        <li><a class="dropdown-item" th:href="@{/logout}">退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>